import 'package:Flutter_Demo/core/router/router.dart';
import 'package:Flutter_Demo/core/viewmodel/favor_view_model.dart';
import 'package:Flutter_Demo/core/viewmodel/fliter_view_model.dart';
import 'package:Flutter_Demo/core/viewmodel/meal_view_model.dart';
import 'package:Flutter_Demo/ui/pages/main/main.dart';
import 'package:Flutter_Demo/ui/shared/app_theme.dart';
import 'package:Flutter_Demo/ui/shared/size_fit.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

void main() {
  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (ctx) => MYMealViewModel()),
        ChangeNotifierProvider(create: (ctx) => MYFavorViewModel()),
        ChangeNotifierProvider(create: (ctx) => MYFliterViewModel()),
        ChangeNotifierProxyProvider<MYFliterViewModel, MYMealViewModel>(
          create: (ctx) => MYMealViewModel(),
          update: (ctx, fliterViewModel, mealViewModel) {
            mealViewModel.updateFliters(fliterViewModel);
            return mealViewModel;
          },
        )

        ],
      child: MyApp(),
    )
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // 对MYSizeFit进行初始化
    MYSizeFit.initialize();

    return MaterialApp(
      title: '美食广场',
      // 主题
      theme: MYAppTheme.normalTheme,
      // 路由
      initialRoute: MYRouter.initialRoute,
      routes: MYRouter.routes,
      onGenerateRoute: MYRouter.generateRoute,
      onUnknownRoute: MYRouter.unknownRoute,

    );
  }
}








































